<template>
    <view>
        <cu-custom style="height: 0px;" class="navBox" bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">我的任务列表</block>
		</cu-custom>

        <view class="missionTop">
            <u-search @change="searchWord" placeholder="请输入关键字" v-model="searchText"
                :show-action='false'></u-search>
        </view>
		
		<!-- <z-pages ref="pagingzhipai" v-model="dataAdminList" @query="queryAllList" auto-show-back-to-top="true"> -->
			<!-- 头部开始 -->
			<view class="goods-header-wrap">
			    <view class="goods-header-item goods-header-item-action" :class="{'goods-header-item-active' : 1 == goodsNav}" @click="setNav(1)">
			        工作中
			    </view>
				<view class="goods-header-item goods-header-item-action" :class="{'goods-header-item-active' : 3 == goodsNav}" @click="setNav(3)">
				    已逾期
				</view>
			    <view class="goods-header-item goods-header-item-action" :class="{'goods-header-item-active' : 2 == goodsNav}" @click="setNav(2)">
			        所有任务
			    </view>
			</view>
			
			<!-- 内容 -->
			<view >
				
				<view v-if="goodsNav==1">
					<view v-if="myList.length > 0">
						<view v-for="item in showMyList" class="goods-item-wrap" :key="item.Id">
						    <view class="goods-content-wrap">
						        <view @click="goJobDetail(item.Id,item.WorkFlowName)" class="goods-name">
						            <view class="goods-name-title">{{item.TaskName}}</view>
						            <view class="select-icon"></view>
						        </view>
						        <view @click="goJobDetail(item.Id,item.WorkFlowName)" class="goods-stock-wrap">
						            <view class="goods-stock left-stock">已维保 / 需维保</view>
						            <view class="goods-stock right-stock">{{item.NewCount}}/{{item.ALLCount}}</view>
						        </view>
						        <view @click="goJobDetail(item.Id,item.WorkFlowName)" class="goods-stock-wrap">
						            <view class="goods-stock left-stock">当前步骤</view>
						            <view class="goods-stock right-stock">{{item.NewTaskNames}}</view>
						        </view>
						        <view @click="goJobDetail(item.Id,item.WorkFlowName)" class="goods-stock-wrap">
						            <view class="goods-stock left-stock">人员</view>
						            <view class="goods-stock right-stock">{{item.NewUserNames}}</view>
						        </view>
						        <view class="goods-stock-wrap" style="border-bottom: 1px solid #F3F4F8;">
						            <view class="goods-stock left-stock">周期</view>
						            <view class="goods-stock-time right-stock">{{item.StartTime.split(' ')[0]}}--{{item.EndTime.split(' ')[0]}}</view>
						        </view>
						        <view class="goods-price2">{{item.WorkFlowName}}</view>
						        <view class="publish-goods-btn1">{{item.StatusName}}</view>
						    </view>
						</view>
						<view class="bottomTips">
							<view v-if="showMyMore" class="" @click="uploadMoreMyList()">
								加载更多...
							</view>
							<view v-if="!showMyMore"  class="">
								没有更多了
							</view>
						</view>
					</view>
					<view v-if="myList.length == 0">
						暂无数据
					</view>
				    
				</view>
				<view v-if="goodsNav==2">
					<view v-if="allList.length > 0">
						<view v-for="item in showAllList" class="goods-item-wrap" :key="item.Id">
						    <view class="goods-content-wrap">
						        <view @click="goJobDetail(item.Id,item.WorkFlowName)" class="goods-name">
						            <view class="goods-name-title">{{item.TaskName}}</view>
						            <view class="select-icon"></view>
						        </view>
						        <view @click="goJobDetail(item.Id,item.WorkFlowName)" class="goods-stock-wrap">
						            <view class="goods-stock left-stock">已维保 / 需维保</view>
						            <view class="goods-stock right-stock">{{item.NewCount}}/{{item.ALLCount}}</view>
						        </view>
						        <view @click="goJobDetail(item.Id,item.WorkFlowName)" class="goods-stock-wrap">
						            <view class="goods-stock left-stock">当前步骤</view>
						            <view class="goods-stock right-stock">{{item.NewTaskNames}}</view>
						        </view>
						        <view @click="goJobDetail(item.Id,item.WorkFlowName)" class="goods-stock-wrap">
						            <view class="goods-stock left-stock">人员</view>
						            <view class="goods-stock right-stock">{{item.NewUserNames}}</view>
						        </view>
						        <view class="goods-stock-wrap" style="border-bottom: 1px solid #F3F4F8;">
						            <view class="goods-stock left-stock">周期</view>
						            <view class="goods-stock-time right-stock">{{item.StartTime.split(' ')[0]}}--{{item.EndTime.split(' ')[0]}}</view>
						        </view>
								<view class="goods-price2">{{item.WorkFlowName}}</view>
						        <view class="publish-goods-btn1">{{item.StatusName}}</view>
						    </view>
						</view>
						<view class="bottomTips">
							<view v-if="showAllMore" class="" @click="uploadMoreAllList()">
								加载更多...
							</view>
							<view v-if="!showAllMore"  class="">
								没有更多了
							</view>
						</view>
					</view>
					<view v-if="allList.length == 0">
						暂无数据
					</view>
				    
				</view>
				
				<view v-if="goodsNav==3">
					<view v-if="passList.length > 0">
						<view v-for="item in showPassList" class="goods-item-wrap" :key="item.Id">
						    <view class="goods-content-wrap">
						        <view @click="goJobDetail(item.Id,item.WorkFlowName)" class="goods-name">
						            <view class="goods-name-title">{{item.TaskName}}</view>
						            <view class="select-icon"></view>
						        </view>
						        <view @click="goJobDetail(item.Id,item.WorkFlowName)" class="goods-stock-wrap">
						            <view class="goods-stock left-stock">已维保 / 需维保</view>
						            <view class="goods-stock right-stock">{{item.NewCount}}/{{item.ALLCount}}</view>
						        </view>
						        <view @click="goJobDetail(item.Id,item.WorkFlowName)" class="goods-stock-wrap">
						            <view class="goods-stock left-stock">当前步骤</view>
						            <view class="goods-stock right-stock">{{item.NewTaskNames}}</view>
						        </view>
						        <view @click="goJobDetail(item.Id,item.WorkFlowName)" class="goods-stock-wrap">
						            <view class="goods-stock left-stock">人员</view>
						            <view class="goods-stock right-stock">{{item.NewUserNames}}</view>
						        </view>
						        <view class="goods-stock-wrap" style="border-bottom: 1px solid #F3F4F8;">
						            <view class="goods-stock left-stock">周期</view>
						            <view class="goods-stock-time right-stock">{{item.StartTime.split(' ')[0]}}--{{item.EndTime.split(' ')[0]}}</view>
						        </view>
						        <view class="goods-price2">{{item.WorkFlowName}}</view>
						        <view class="publish-goods-btn1">{{item.StatusName}}</view>
						    </view>
						</view>
						<view class="bottomTips">
							<view v-if="showPassMore" class="" @click="uploadMorePassList()">
								加载更多...
							</view>
							<view v-if="!showPassMore"  class="">
								没有更多了
							</view>
						</view>
					</view>
					<view v-if="passList.length == 0">
						暂无数据
					</view>
				    
				</view>
				        
			</view>
		<!-- </z-pages> -->
        
      
    </view>
</template>

<script>
	import request from '@/common/request.js'
export default {
    data(){
        return {
            goodsNav: 1,
			searchText:'',
            myList: [],
            allList: [],
			passList:[],
			showMyList: [],
			showAllList:[],
			showPassList:[],
			myListPageindex: 1,
			allListPageindex: 1,
			passListPageindex: 1,
			showMyMore: true,
			showAllMore: true,
			showPassMore: true
        }
    },
    onLoad(){
		let that = this
		that.getMyData(1)
		that.getAllData(1)
		that.getPassData(1)
    },
    methods: {
        searchWord(e){
			let that =this
			that.searchText = e
			that.showMyList = that.myList.filter(item => item.WorkFlowName.includes(e) || item.NewUserNames.includes(e) || item.NewTaskNames.includes(e) || item.TaskName.includes(e))
			that.showAllList = that.allList.filter(item => item.WorkFlowName.includes(e) || item.NewUserNames.includes(e) || item.NewTaskNames.includes(e) || item.TaskName.includes(e))
			that.showPassList = that.passList.filter(item => item.WorkFlowName.includes(e) || item.NewUserNames.includes(e) || item.NewTaskNames.includes(e) || item.TaskName.includes(e))
        },
		getMyData(index){
			let that =this
			let opts = {
				url: 'WorkflowApi/GetMyWorkList',
				method:'get'
			}
			let data = {
				pageindex: index,
				pagesize: 10,
				KeyWords:''
			}
			request.httpTokenRequest(opts, data).then(res=> {
				that.myList = that.myList.concat(res.data.Data)
				that.showMyList = that.myList
				if (that.myList.length == res.data.Total) {
					that.showMyMore = false
				}
			})
		},
		uploadMoreMyList(){
			let that = this
			that.getMyData(++that.myListPageindex)
		},
		getAllData(index){
			let that =this
			let opts = {
				url: 'WorkflowApi/GetAllWorkList',
				method:'get'
			}
			let data = {
				pageindex: index,
				pagesize: 10,
				KeyWords:''
			}
			request.httpTokenRequest(opts, data).then(res=> {
				that.allList = that.allList.concat(res.data.Data)
				that.showAllList = that.allList
				if (that.allList.length == res.data.Total) {
					that.showAllMore = false
				}
			})
		},
		uploadMoreAllList(){
			let that = this
			that.getAllData(++that.allListPageindex)
		},
		//GetMyPassWorkList
		getPassData(index){
			let that =this
			let opts = {
				url: 'WorkflowApi/GetMyPassWorkList',
				method:'get'
			}
			let data = {
				pageindex: index,
				pagesize: 10,
				KeyWords:''
			}
			request.httpTokenRequest(opts, data).then(res=> {
				that.passList = that.passList.concat(res.data.Data)
				that.showPassList = that.passList
				if (that.passList.length == res.data.Total) {
					that.showPassMore = false
				}
			})
		},
		uploadMorePassList(){
			let that = this
			that.getPassData(++that.passListPageindex)
		},
        setNav(goodsNav) {
			let that=this
			that.goodsNav=goodsNav
			that.searchText=''
		},
        goJobDetail(Id,WorkFlowName) {
            uni.navigateTo({
                url: '/pages-weibao/missionDetail?WorkId='+Id
            })
        },
        goOverdueWb(){
            uni.navigateTo({
                url: '/pages-weibao/wbIndex'
            })
        },
        goWB(){
            uni.navigateTo({
                url: '/pages-weibao/wbIndex'
            })
        }
    }
}
</script>

<style lang="scss" scoped>
.missionTop{
    padding: 30rpx 20rpx;
    background-color: white;
}

.flex-between{
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.goods-header-wrap {
    display: flex;
    align-items: center;
    padding: 24rpx;
    background: #FFFFFF;
    margin-bottom: 10rpx;

	.goods-header-item{
		width:49%;
		text-align: center;
	}
	.goods-header-item-active{
		font-size: 30rpx;
		color: #333333;
		font-weight: bold;
		position: relative;
	}
	.goods-header-item-active::after{
		position: absolute;
		left: 50%;
		right: 0;
		background: #4372fe;
		height: 8rpx;
		content: "";
		bottom: -12rpx;
		width: 60rpx;
		margin-left: -30rpx;
		border-radius: 200rpx;
	}
	.goods-header-item-action {
		// font-size: 32rpx;
		// font-color: #333333;
		// font-weight: bold;
		position: relative;
	}
}

.goods-item-wrap {
		border-radius: 8rpx;
		background: #FFFFFF;
		display: flex;
		padding: 24rpx;
		margin: 12rpx;
		//width:100%;
		.goods-content-wrap{
			width: 100%;
		}
		.goods-name {
			width: 100%;
			font-size: 32rpx;
			font-weight: bold;
			display: flex;
			position: relative;
			border-bottom: 1px solid #F3F4F8;
			padding-bottom: 20rpx;
		}
		.goods-name-title{
			display: block;
			float: left;
		}
        .select-icon{
            border-bottom: 3rpx solid #999;
            border-right: 3rpx solid #999;
            width: 16rpx;
            height: 16rpx;
            transform: rotate(-45deg);
            position: absolute;
            right: 20rpx;
            top: 14rpx;
        }
		.goods-name-type{
			display: block;
			float:right;
			color: #3B69FD;
			margin-right: 20rpx;
		}
		.goods-stock-wrap {
			display: flex;
			color: #969696;
			font-size: 24rpx;
			margin-top: 20rpx;
			justify-content: space-between;
		}
		
		.goods-stock {
			margin-right: 24rpx;
			font-size: 28rpx;
			color: #636571;
			line-height: 32rpx;
			&.left-stock{
				flex: 0.35;
				color: #b3b3b3;
			}
			&.right-stock{
				flex: 0.65;
				text-align: right;
			}
		}
		.goods-stock-isok{
			margin-right: 10rpx;
			font-size: 38rpx;
			color: #00B52A;
			line-height: 32rpx;
			font-weight: 700;
		}
		.goods-stock-middle{
			margin-right: 10rpx;
			font-size: 38rpx;
			color: #636571;
			line-height: 32rpx;
			font-weight: 700;
		}
		.goods-stock-notok{
			margin-right: 24rpx;
			font-size: 38rpx;
			color: #F53F3E;
			line-height: 32rpx;
			font-weight: 700;
		}
		.goods-stock-time {
			margin-right: 24rpx;
			font-size: 28rpx;
			color: #e7612e;
			padding-bottom: 20rpx;
			&.right-stock{
				flex: 0.65;
				text-align: right;
			}
		}
		.goods-shangxiaxian {
			font-size:24rpx;
			color: #3F71C4;
			margin-top: 14rpx;
		}
		
		.goods-price1 {
			font-size:26rpx;
			color: #3B69FD;
			margin-top: 20rpx;
			font-weight:500;
			width: 160rpx;
			display: block;
			float:left;
			background-color: #D0D9F7;
			border-radius: 4rpx;
			text-align: center;
			height: 54rpx;
			line-height: 54rpx;
		}
		.goods-price2 {
			font-size:26rpx;
			color: #15C9CA;
			margin-top: 20rpx;
			font-weight:500;
			width: 160rpx;
			display: block;
			float:left;
			background-color: #C8ECEC;
			border-radius: 14rpx;
			text-align: center;
			height: 54rpx;
			line-height: 54rpx;
		}
    .publish-goods-btn {
		width:160rpx;
		background: #e7612e;
		color: #FFFFFF;
		height: 54rpx;
		line-height: 54rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 82rpx;
		float:right;
		margin-right: 20rpx;
		margin-top: 20rpx;
	}
	
	.publish-goods-btn1 {
		width:160rpx;
		background: #3B69FD;;
		color: #FFFFFF;
		height: 54rpx;
		line-height: 54rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 82rpx;
		float:right;
		margin-right: 20rpx;
		margin-top: 20rpx;
	}
	
	.publish-goods-btn2 {
		width:160rpx;
		background: #00B52A;;
		color: #FFFFFF;
		height: 54rpx;
		line-height: 54rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 82rpx;
		float:right;
		margin-right: 20rpx;
		margin-top: 20rpx;
	}


}

.bottomTips {
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 20rpx 0 40rpx;
}
</style>